﻿using System;
using Util.Model;

namespace DataBase.DBmodels;

public partial class ProductionData
{
    /// <summary>
    /// SN_ID
    /// </summary>
    public int Id { get; set; }

    /// <summary>
    /// 类型
    /// </summary>
    public int ? Type { get; set; }
    /// <summary>
    /// SN编号
    /// </summary>
    public string ? Sn { get; set; } 

    /// <summary>
    /// 电缸编号
    /// </summary>
    public int? CylinderNo { get; set; }

    /// <summary>
    /// 最大压力值
    /// </summary>
    public double? MaxPressureValue { get; set; }

    /// <summary>
    /// 最大位移值
    /// </summary>
    public double? MaxPositionValue { get; set; }

    /// <summary>
    /// 衬套版本
    /// </summary>
    public string? NowTime { get; set; }

    /// <summary>
    /// 判断结果，
    /// </summary>
    public string? Result { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreateTime { get; set; }

    public CSVData ToCSVData(ProductionData productionDataLog)
    {
        return new CSVData
        {
            Cylinder = productionDataLog.Result==null?"": productionDataLog.Result,
            CurrentPosition = productionDataLog.MaxPositionValue ?? 0,
            CrateTime = productionDataLog.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
        };
    }
    public CSVData2 ToCSVData2(ProductionData productionDataLog)
    {
        return new CSVData2
        {
            Cylinder = productionDataLog.Result == null ? "" : productionDataLog.Result,
            Parm1 = productionDataLog.MaxPressureValue ?? 0,
            Parm2 = productionDataLog.MaxPositionValue ?? 0,
            CrateTime = productionDataLog.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
        };
    }
    public CSVData3 ToCSVData3(ProductionData productionDataLog)
    {
        return new CSVData3
        {
            Cylinder = productionDataLog.Result == null ? "" : productionDataLog.Result,
            Parm1 = productionDataLog.MaxPressureValue ?? 0,
            Parm2 = productionDataLog.MaxPositionValue ?? 0,
            Parm3 = productionDataLog.NowTime??"",
            CrateTime = productionDataLog.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
        };
    }
}
